How do I change these modules so that the communication is bidirectional (inout)? I'm simply not sure how to modify the code. I know i need to add an inout port but I don't know how to do it. I have watched multiple tutorials but I can't figure it out.
module mem(
input logic clk, we , // write enable bit, active low
input logic [n-1:0] in ,
input logic [m-1:0] addr ,
output logic [n-1:0] out ) ;
parameter n = 1, m = 1, k = 1 << m ; //data width, address
width, size
logic [n-1:0] memo [k-1:0] ;
// array of 2^m elements, each being an n-bit wide register
assign out = memo[addr] ;
always_ff @(posedge clk) begin
if (! we ) memo[addr] = in ;
end
endmodule
-----------------------------
module stack(
input logic clk , rst , // clock and reset
input logic [1:0] op , //operation PUSH or POP (one-hot)
input logic [n-1:0] pushval , // PUSH argument
output logic [n-1:0] popval ) ; // POP result
parameter n = 1, m = 1, k = 1<< m ; // data width, address
width, size
logic [m-1:0] addr ; // address for memory
logic up, down ; // breaking op down to 2 separate bits
logic [n-1:0] in ; // input for memory
logic [n-1:0] out ; // output from memory
logic we ; // write enable signal for memory
logic [m-1:0] addr1 ; // counter output
assign up = (addr == {m{1'b1}}) ? 1'b0 : op[1] ;
assign down = (addr == {m{1'b0}}) ? 1'b0 : op[0] ;
assign in = (op == 2'b10) ? pushval : {n{1'b0}};
assign we = rst ? 1'b1 : !(up ^ down) ;
assign addr = (op == 2'b10) ? addr1 + 1'b1 : addr1 ;
// instantiate memory module
mem #(n,m,k) memory(clk, we, in, addr, out) ;
assign popval = out ;
// instantiate counter module
udl #(m) counter(clk, rst, up, down, addr1) ;
endmodule
I am just told to redesign the modules so that the data communication takes place through a bidirectional bus connection.
How do I change these modules so that the communication is bidirectional (inout)? I'm simply not...
How do I change these modules so that the communication is bidirectional (inout)? I'm simply not sure how to modify the code. I know i need to add an inout port but I don't know how to do it. I have watched multiple tutorials but I can't figure it out. module mem( input logic clk, we , // write enable bit, active low input logic [n-1:0] in , input logic [m-1:0] addr , output logic [n-1:0] out ) ; parameter...
I need help writing a test bench for the following Verilog code module CU(IE, WE, WA, RAE, RAA, RBE, RBA, ALU, SH, OE, start, clk, reset, Ng5); //nG5 denotes (N>5); input start, clk, reset; output IE, WE, RAE, RBE, OE; output [1:0] WA, RAA, RBA, SH; output [2:0] ALU; input wire Ng5; reg [1:0] state; reg [1:0] nextstate; parameter S0 = 3'b000; parameter S1 = 3'b001;...
How do I create a testbench with the verilog code below? module ganada(Clk, U1, D2, U2, D3, U3, D4, F1, F2, F3, F4, CF, S); input Clk, U1, D2, U2, D3, U3, D4, F1, F2, F3, F4; output [6:0] CF, S; reg [6:0] CF, S; reg [1:0] SS, B, NS; initial begin NS=2'b00; SS=2'b00; end always@(posedge Clk) begin case(NS) 2'b00: CF=7'b1111001; 2'b01: CF=7'b0100100; 2'b10: CF=7'b0110000; 2'b11: CF=7'b0011001; endcase case(SUD) 2'b00: S=7'b1000000; 2'b01: S=7'b1111001; 2'b10: S=7'b0100100; default: S=7'b0000000; endcase if(U1==1 ||...
WRITE THE CODE IN VERILOG: Instead of using Registers, USE D FLIP FLOPS and a clock. Include the logic for a reset A sequential circuit with three D flip-flops A, B, and C, a trigger x, and an output z1, and zo. On this state machine diagram, the label of the states are in the order of (ABC), the transition is the one bit x, and the output is under the forward slash. x/z1zo. The start state is 001 0/01...
A sequential circuit has one input (X), a clock input (CLK), and two outputs (S and V). X, S and V are all one-bit signals. X represents a 4-bit binary number N, which is input least significant bit first. S represents a 4-bit binary number equal to N + 3, which is output least significant bit first. At the time the fourth input occurs, V = 1 if N + 3 is too large to be represented by 4 bits;...
In this lab, you will design a finite state machine to control the tail lights of an unsual car. There are three lights on each side that operate in sequence to indicate thedirection of a turn. Figure ! shows the tail lights and Figure 2 shows the flashing sequence for (a) left turns and (b) right rums. ZOTTAS Figure 28:8: BCECECece BCECECECes BCECECECB BCECECBCB 8888 Figure 2 Part 1 - FSM Design Start with designing the state transition diagram for...
How do I do this C++ in a Unix Environment assignment Given dot1m.c 1. The program (dot1m.c) uses mutex to lock and unlock the shared resource (dotstr.sum) for access control as shown below. pthread_mutex_lock (&mutexsum); dotstr.sum += mysum; printf("Thread %ld did %d to %d: mysum=%f global sum=%f\n", offset,start,end,mysum,dotstr.sum); pthread_mutex_unlock (&mutexsum); 2. Modify dot1m.c program to use reader-writer lock (instead of mutex). Replace the codes (for mutex) by the codes (for reader-writer lock). To initialize reader-writer lock, pthread_rwlock_initializer. At the end,...
There is an example below Now that everything is working you can try the following exercises. To complete them you will need to refer to the documentation in Appendix A The MiteASM Assembler and Appendix B The MiteFPGA Processor. Write an assembly language program for an over counter for a cricket umpire. This should 1. display a count on the 7-segment display. The count should increase by 1 when button 0 is pressed. It should reset to 0 when button...
Need this in C The starter code is long, if you know how to do it in other way please do. Do the best you can please. Here's the starter code: // ----------------------------------------------------------------------- // monsterdb.c // ----------------------------------------------------------------------- #include #include #include // ----------------------------------------------------------------------- // Some defines #define NAME_MAX 64 #define BUFFER_MAX 256 // ----------------------------------------------------------------------- // Structs typedef struct { char name[NAME_MAX]; int hp; int attackPower; int armor; } Character; typedef struct { int size; Character *list; } CharacterContainer; // ----------------------------------------------------------------------- //...
Please help with my car traffic simulator! Code that I already have below, I do not know how to start it off! public class IntersectionSimulation { private final static int EAST_WEST_GREEN_TIME = 30 ; private final static int[] NORTH_SOUTH_GREEN_TIMES = { 20, 24, 30, 42 } ; private final static int[] CAR_INTERSECTION_RATES = { 3, 5, 10 } ; private final static int[] CAR_QUEUEING_RATES = { 5, 10, 30 } ; private final static int[] EXPERIMENT_DURATIONS = { 3*60, 5*60,...