mirror of
https://github.com/Silicon1602/srdl2sv.git
synced 2024-12-22 06:58:41 +00:00
Add simple_rw_reg example with reset signals
This commit is contained in:
parent
d8add0d5f2
commit
9cb53f0fb0
@ -2,26 +2,46 @@
|
|||||||
// - A 1-dimensional register
|
// - A 1-dimensional register
|
||||||
// - A 2-dimensional register
|
// - A 2-dimensional register
|
||||||
// - A 3-dimensional register
|
// - A 3-dimensional register
|
||||||
//
|
|
||||||
// Note that no reset is defined, so none of the registers will be
|
// Not defined as field_reset!
|
||||||
// resetable.
|
signal {activelow; async;} async_rst_n;
|
||||||
|
signal {activehigh; sync;} sync_rst_n;
|
||||||
|
|
||||||
addrmap simple_rw_reg {
|
addrmap simple_rw_reg {
|
||||||
// 1-D register
|
// 1-D register
|
||||||
reg {
|
reg {
|
||||||
|
desc = "None of the fields in this register have a reset";
|
||||||
|
|
||||||
field {sw=rw; hw=rw; we;} f1 [15:0];
|
field {sw=rw; hw=rw; we;} f1 [15:0];
|
||||||
field {sw=rw; hw=rw; we;} f2 [31:16];
|
field {sw=rw; hw=rw; we;} f2 [31:16];
|
||||||
} register_1d;
|
} register_1d;
|
||||||
|
|
||||||
// 2-D register
|
// 2-D register
|
||||||
reg {
|
reg {
|
||||||
|
desc = "Both fields are connected to a reset signal, but
|
||||||
|
only one field actually gets a reset value.";
|
||||||
|
|
||||||
field {sw=rw; hw=rw; we;} f1 [15:0];
|
field {sw=rw; hw=rw; we;} f1 [15:0];
|
||||||
field {sw=rw; hw=rw; we;} f2 [31:16];
|
field {sw=rw; hw=rw; we;} f2 [31:16];
|
||||||
|
|
||||||
|
f1->resetsignal = async_rst_n;
|
||||||
|
f2->resetsignal = async_rst_n;
|
||||||
|
|
||||||
|
f1->reset = 0;
|
||||||
} register_2d[2];
|
} register_2d[2];
|
||||||
|
|
||||||
// 3-D register
|
// 3-D register
|
||||||
reg {
|
reg {
|
||||||
|
desc = "Similar to register_2d, but now the resets are
|
||||||
|
reset synchronously.";
|
||||||
|
|
||||||
field {sw=rw; hw=rw; we;} f1 [15:0];
|
field {sw=rw; hw=rw; we;} f1 [15:0];
|
||||||
field {sw=rw; hw=rw; we;} f2 [31:16];
|
field {sw=rw; hw=rw; we;} f2 [31:16];
|
||||||
|
|
||||||
|
f1->resetsignal = sync_rst_n;
|
||||||
|
f2->resetsignal = sync_rst_n;
|
||||||
|
|
||||||
|
f1->reset = 0;
|
||||||
|
// Show what happens if a field is not reset
|
||||||
} register_3d[2][2];
|
} register_3d[2][2];
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*
|
*
|
||||||
* Generation information:
|
* Generation information:
|
||||||
* - User: : dpotter
|
* - User: : dpotter
|
||||||
* - Time : November 26 2021 16:32:58
|
* - Time : November 26 2021 16:52:16
|
||||||
* - Path : /home/dpotter/srdl2sv/examples/simple_rw_reg
|
* - Path : /home/dpotter/srdl2sv/examples/simple_rw_reg
|
||||||
* - RDL file : ['simple_rw_reg.rdl']
|
* - RDL file : ['simple_rw_reg.rdl']
|
||||||
* - Hostname : ArchXPS
|
* - Hostname : ArchXPS
|
||||||
@ -71,7 +71,8 @@ module simple_rw_reg
|
|||||||
|
|
||||||
(
|
(
|
||||||
// Reset signals declared for registers
|
// Reset signals declared for registers
|
||||||
|
input async_rst_n,
|
||||||
|
input sync_rst_n,
|
||||||
|
|
||||||
// Ports for 'General Clock'
|
// Ports for 'General Clock'
|
||||||
input clk,
|
input clk,
|
||||||
@ -277,13 +278,18 @@ begin
|
|||||||
// name : f1 (register_2d[15:0])
|
// name : f1 (register_2d[15:0])
|
||||||
// access : hw = rw
|
// access : hw = rw
|
||||||
// sw = rw (precedence)
|
// sw = rw (precedence)
|
||||||
// reset : - / -
|
// reset : active_low / asynchronous
|
||||||
// flags : ['sw', 'we']
|
// flags : ['sw', 'we', 'resetsignal']
|
||||||
// external : False
|
// external : False
|
||||||
// storage type : StorageType.FLOPS
|
// storage type : StorageType.FLOPS
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
|
|
||||||
always_ff @(posedge clk)
|
always_ff @(posedge clk or negedge async_rst_n)
|
||||||
|
if (!async_rst_n)
|
||||||
|
begin
|
||||||
|
register_2d__f1_q[gv_a] <= 16'd0;
|
||||||
|
end
|
||||||
|
else
|
||||||
begin
|
begin
|
||||||
if (register_2d_sw_wr[gv_a])
|
if (register_2d_sw_wr[gv_a])
|
||||||
begin
|
begin
|
||||||
@ -306,13 +312,18 @@ begin
|
|||||||
// name : f2 (register_2d[31:16])
|
// name : f2 (register_2d[31:16])
|
||||||
// access : hw = rw
|
// access : hw = rw
|
||||||
// sw = rw (precedence)
|
// sw = rw (precedence)
|
||||||
// reset : - / -
|
// reset : active_low / asynchronous
|
||||||
// flags : ['sw', 'we']
|
// flags : ['sw', 'we', 'resetsignal']
|
||||||
// external : False
|
// external : False
|
||||||
// storage type : StorageType.FLOPS
|
// storage type : StorageType.FLOPS
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
|
|
||||||
always_ff @(posedge clk)
|
always_ff @(posedge clk or negedge async_rst_n)
|
||||||
|
if (!async_rst_n)
|
||||||
|
begin
|
||||||
|
register_2d__f2_q[gv_a] <= 16'dx;
|
||||||
|
end
|
||||||
|
else
|
||||||
begin
|
begin
|
||||||
if (register_2d_sw_wr[gv_a])
|
if (register_2d_sw_wr[gv_a])
|
||||||
begin
|
begin
|
||||||
@ -380,13 +391,18 @@ begin
|
|||||||
// name : f1 (register_3d[15:0])
|
// name : f1 (register_3d[15:0])
|
||||||
// access : hw = rw
|
// access : hw = rw
|
||||||
// sw = rw (precedence)
|
// sw = rw (precedence)
|
||||||
// reset : - / -
|
// reset : active_high / synchronous
|
||||||
// flags : ['sw', 'we']
|
// flags : ['sw', 'we', 'resetsignal']
|
||||||
// external : False
|
// external : False
|
||||||
// storage type : StorageType.FLOPS
|
// storage type : StorageType.FLOPS
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
|
|
||||||
always_ff @(posedge clk)
|
always_ff @(posedge clk)
|
||||||
|
if (sync_rst_n)
|
||||||
|
begin
|
||||||
|
register_3d__f1_q[gv_a][gv_b] <= 16'd0;
|
||||||
|
end
|
||||||
|
else
|
||||||
begin
|
begin
|
||||||
if (register_3d_sw_wr[gv_a][gv_b])
|
if (register_3d_sw_wr[gv_a][gv_b])
|
||||||
begin
|
begin
|
||||||
@ -409,13 +425,18 @@ begin
|
|||||||
// name : f2 (register_3d[31:16])
|
// name : f2 (register_3d[31:16])
|
||||||
// access : hw = rw
|
// access : hw = rw
|
||||||
// sw = rw (precedence)
|
// sw = rw (precedence)
|
||||||
// reset : - / -
|
// reset : active_high / synchronous
|
||||||
// flags : ['sw', 'we']
|
// flags : ['sw', 'we', 'resetsignal']
|
||||||
// external : False
|
// external : False
|
||||||
// storage type : StorageType.FLOPS
|
// storage type : StorageType.FLOPS
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
|
|
||||||
always_ff @(posedge clk)
|
always_ff @(posedge clk)
|
||||||
|
if (sync_rst_n)
|
||||||
|
begin
|
||||||
|
register_3d__f2_q[gv_a][gv_b] <= 16'dx;
|
||||||
|
end
|
||||||
|
else
|
||||||
begin
|
begin
|
||||||
if (register_3d_sw_wr[gv_a][gv_b])
|
if (register_3d_sw_wr[gv_a][gv_b])
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user