Forum Discussion
Altera_Forum
Honored Contributor
14 years agoSharing memory: Nios and HDL-module
Hi All!
I need to share SRAM between nios II and HDL-module. What component I need in SOPC? I have a hand-made component Bridge to SRAM (MM slave- MM tristate master) and MM Tristate slave component of SRAM. SRAM in CPU working well. But I can't to connect HDL to SRAM-Bridge in quartus (some error). What is wrong? Error: Net "CLOCK_50", which fans out to "addr_for_write[0]", cannot be assigned more than one value Error: Net is fed by "nios:DUT|bridge_2_sram_writen" Error: Net is fed by "CLOCK_50" Code of top-level
module DE2_115_CAMERA
CLOCK2_50,
//////////////////// SRAM Interface ////////////////
SRAM_DQ, // SRAM Data bus 16 Bits
SRAM_ADDR, // SRAM Address bus 18 Bits
SRAM_UB_N, // SRAM High-byte Data Mask
SRAM_LB_N, // SRAM Low-byte Data Mask
SRAM_WE_N, // SRAM Write Enable
SRAM_CE_N,// SRAM Chip Enable
SRAM_OE_N, // SRAM Output Enable
...
);
input CLOCK_50;
//////////////////////// SRAM Interface ////////////////////////
inout SRAM_DQ;
output SRAM_ADDR;
output SRAM_UB_N;
output SRAM_LB_N;
output SRAM_WE_N;
output SRAM_CE_N;
output SRAM_OE_N;
....
nios DUT(
.clk_0 (CLOCK_50),
// SRAM
.bridge_2_sram_address (SRAM_ADDR),
.bridge_2_sram_byteenablen ({SRAM_UB_N, SRAM_LB_N}),
.bridge_2_sram_data (SRAM_DQ),
.bridge_2_sram_writen (SRAM_WE_N),
...
);
reg pixcount;
reg addr_for_write;
reg colour;
// fill first 640 item of SRAM
always @(posedge CLOCK_50)
begin
if (!KEY)
begin
colour <= 16'h00ff;
pixcount <= 0;
end
else
begin
if (pixcount < 640)
begin
addr_for_write <= pixcount;
pixcount <= pixcount + 1;
end
else
begin
addr_for_write <= 20'hzzzzz;
colour <= 16'hzzzzz;
end
end
end
assign SRAM_ADDR = addr_for_write;
assign SRAM_DQ = colour;
4 Replies
- Altera_Forum
Honored Contributor
If I correctly understood, your sram is accessed both by the above nios:DUT module and by Nios II processor through a tristate bridge.
You can't connect two tristate masters to a single tristate device. Each master would drive the same signals thus causing bus contention. This is possible only if you have arbitration logic for regulating bus accesses, namely holding one of the masters while the other is accessing the bus. AFAIK this function is not provided by the Avalon tristate bridge. You must use a single tristate bridge and design your module as an Avalon master, so you can connect it before the ts bridge. - Altera_Forum
Honored Contributor
Yes, you are correctly understood.Sory for my English:)
I have created SOPC-component of Master Avalon-MM with conduit input (like DMA-controller). My master need to hold a bus (same as DMA-controller). What signal I can use for holding bus? lock? I can't find documentation witch explain arbitration on Avalon bus. I known only about AN184 (extras.springer.com/2001/978-0-306-47635-8/an/an184.pdf). Thank you. - Altera_Forum
Honored Contributor
Avalon arbitration is explained in sopc user guide:
http://www.altera.com/literature/ug/ug_sopc_builder.pdf Arbitration logic is embedded in the Avalon system interconnection fabric. The arbiter holds a master with the waitrequest signal, so you only need to check this signal. You don't manage request/grant signals like in a classic shared bus architecture. lock is only used to prevent arbiter from interrupting bursts and granting access to another master. - Altera_Forum
Honored Contributor
oh, thank you for link!