How do I change these modules so that the communication is bidirectional (inout)?Randomly Map Bits in Verilogbidirectional tlm port in systemverilogVerilog Program Counter with branchinggaussian noise in systemVerilogWhy do I have to reverse the concatenation order for inputs and outputs when instantiating this module?How to model bidirectional transport delayValue not distributed in timestate transition diagram from verilog code of 8 bit processorConnection inout interface signal to pinQuartus Prime compilation ROM
The eyes have it
Was there a priest on the Titanic who stayed on the ship giving confession to as many as he could?
Orange material in grout lines - need help to identify
Can anyone identify this tank?
Trapping Rain Water
What makes Ada the language of choice for the ISS's safety-critical systems?
Is open-sourcing the code of a webapp not recommended?
Inconsistent behavior of compiler optimization of unused string
Russian equivalents of "no love lost"
What's up with this leaf?
What are the peak hours for public transportation in Paris?
What can plausibly explain many of my very long and low-tech bridges?
Should I compare a std::string to "string" or "string"s?
Does setting a new type clear the rules text for non-lands?
Can an Aarakocra use a shield while flying?
How Can I Tell The Difference Between Unmarked Sugar and Stevia?
How does a transformer increase voltage while decreasing the current?
How does an ordinary object become radioactive?
How did students remember what to practise between lessons without any sheet music?
Find duplicated column value in CSV
Preventing Employees from either switching to Competitors or Opening Their Own Business
How do I write "Show, Don't Tell" as a person with Asperger Syndrome?
Why doesn't Adrian Toomes give up Spider-Man's identity?
Why don’t airliners have temporary liveries?
How do I change these modules so that the communication is bidirectional (inout)?
Randomly Map Bits in Verilogbidirectional tlm port in systemverilogVerilog Program Counter with branchinggaussian noise in systemVerilogWhy do I have to reverse the concatenation order for inputs and outputs when instantiating this module?How to model bidirectional transport delayValue not distributed in timestate transition diagram from verilog code of 8 bit processorConnection inout interface signal to pinQuartus Prime compilation ROM
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
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 == m1'b1) ? 1'b0 : op[1] ;
assign down = (addr == m1'b0) ? 1'b0 : op[0] ;
assign in = (op == 2'b10) ? pushval : n1'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
system-verilog
add a comment |
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 == m1'b1) ? 1'b0 : op[1] ;
assign down = (addr == m1'b0) ? 1'b0 : op[0] ;
assign in = (op == 2'b10) ? pushval : n1'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
system-verilog
1
you need to be more specific. which inout? why? it looks ok as it is.
– Serge
Mar 24 at 18:15
I am just told to redesign the modules so that the data communication takes place through a bidirectional bus connection.
– mattycodes1995
Mar 24 at 19:48
add a comment |
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 == m1'b1) ? 1'b0 : op[1] ;
assign down = (addr == m1'b0) ? 1'b0 : op[0] ;
assign in = (op == 2'b10) ? pushval : n1'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
system-verilog
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 == m1'b1) ? 1'b0 : op[1] ;
assign down = (addr == m1'b0) ? 1'b0 : op[0] ;
assign in = (op == 2'b10) ? pushval : n1'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
system-verilog
system-verilog
asked Mar 24 at 16:12
mattycodes1995mattycodes1995
1
1
1
you need to be more specific. which inout? why? it looks ok as it is.
– Serge
Mar 24 at 18:15
I am just told to redesign the modules so that the data communication takes place through a bidirectional bus connection.
– mattycodes1995
Mar 24 at 19:48
add a comment |
1
you need to be more specific. which inout? why? it looks ok as it is.
– Serge
Mar 24 at 18:15
I am just told to redesign the modules so that the data communication takes place through a bidirectional bus connection.
– mattycodes1995
Mar 24 at 19:48
1
1
you need to be more specific. which inout? why? it looks ok as it is.
– Serge
Mar 24 at 18:15
you need to be more specific. which inout? why? it looks ok as it is.
– Serge
Mar 24 at 18:15
I am just told to redesign the modules so that the data communication takes place through a bidirectional bus connection.
– mattycodes1995
Mar 24 at 19:48
I am just told to redesign the modules so that the data communication takes place through a bidirectional bus connection.
– mattycodes1995
Mar 24 at 19:48
add a comment |
1 Answer
1
active
oldest
votes
a bus can be designed with multiple writers and readers. An example is the following:
wire bus;
assign bus = wren1 ? data1 : 'z;
assign bus = wren2 ? data2 : 'z;
In the above example the bus is driven either by data or by a high impedance value. Real data always wins. Just make sure that enable signals are not turned on at the same time, or you will get 'x' as the bus value.
you can read the bus value in a normal way, for example:
always_latch
if (rden1)
val = bus;
...
you can pass the bus wire through an inout port, for example
module mem(input clk, wren, [3:0] address, inout[3:0] data);
logic [3:0]memory[15:0];
assign data = !wren ? memory[address] : 'z;
always_ff @(posedge clk)
if (wren)
memory[address] <= data;
endmodule
similarly you can re-design you stack module.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325809%2fhow-do-i-change-these-modules-so-that-the-communication-is-bidirectional-inout%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
a bus can be designed with multiple writers and readers. An example is the following:
wire bus;
assign bus = wren1 ? data1 : 'z;
assign bus = wren2 ? data2 : 'z;
In the above example the bus is driven either by data or by a high impedance value. Real data always wins. Just make sure that enable signals are not turned on at the same time, or you will get 'x' as the bus value.
you can read the bus value in a normal way, for example:
always_latch
if (rden1)
val = bus;
...
you can pass the bus wire through an inout port, for example
module mem(input clk, wren, [3:0] address, inout[3:0] data);
logic [3:0]memory[15:0];
assign data = !wren ? memory[address] : 'z;
always_ff @(posedge clk)
if (wren)
memory[address] <= data;
endmodule
similarly you can re-design you stack module.
add a comment |
a bus can be designed with multiple writers and readers. An example is the following:
wire bus;
assign bus = wren1 ? data1 : 'z;
assign bus = wren2 ? data2 : 'z;
In the above example the bus is driven either by data or by a high impedance value. Real data always wins. Just make sure that enable signals are not turned on at the same time, or you will get 'x' as the bus value.
you can read the bus value in a normal way, for example:
always_latch
if (rden1)
val = bus;
...
you can pass the bus wire through an inout port, for example
module mem(input clk, wren, [3:0] address, inout[3:0] data);
logic [3:0]memory[15:0];
assign data = !wren ? memory[address] : 'z;
always_ff @(posedge clk)
if (wren)
memory[address] <= data;
endmodule
similarly you can re-design you stack module.
add a comment |
a bus can be designed with multiple writers and readers. An example is the following:
wire bus;
assign bus = wren1 ? data1 : 'z;
assign bus = wren2 ? data2 : 'z;
In the above example the bus is driven either by data or by a high impedance value. Real data always wins. Just make sure that enable signals are not turned on at the same time, or you will get 'x' as the bus value.
you can read the bus value in a normal way, for example:
always_latch
if (rden1)
val = bus;
...
you can pass the bus wire through an inout port, for example
module mem(input clk, wren, [3:0] address, inout[3:0] data);
logic [3:0]memory[15:0];
assign data = !wren ? memory[address] : 'z;
always_ff @(posedge clk)
if (wren)
memory[address] <= data;
endmodule
similarly you can re-design you stack module.
a bus can be designed with multiple writers and readers. An example is the following:
wire bus;
assign bus = wren1 ? data1 : 'z;
assign bus = wren2 ? data2 : 'z;
In the above example the bus is driven either by data or by a high impedance value. Real data always wins. Just make sure that enable signals are not turned on at the same time, or you will get 'x' as the bus value.
you can read the bus value in a normal way, for example:
always_latch
if (rden1)
val = bus;
...
you can pass the bus wire through an inout port, for example
module mem(input clk, wren, [3:0] address, inout[3:0] data);
logic [3:0]memory[15:0];
assign data = !wren ? memory[address] : 'z;
always_ff @(posedge clk)
if (wren)
memory[address] <= data;
endmodule
similarly you can re-design you stack module.
answered Mar 24 at 20:25
SergeSerge
4,36021116
4,36021116
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325809%2fhow-do-i-change-these-modules-so-that-the-communication-is-bidirectional-inout%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
you need to be more specific. which inout? why? it looks ok as it is.
– Serge
Mar 24 at 18:15
I am just told to redesign the modules so that the data communication takes place through a bidirectional bus connection.
– mattycodes1995
Mar 24 at 19:48