URL
https://opencores.org/ocsvn/wb_sim_models/wb_sim_models/trunk
Subversion Repositories wb_sim_models
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 2 to Rev 3
- ↔ Reverse comparison
Rev 2 → Rev 3
/tags/start/doc/README.txt
--- tags/start/verilog/wb_mast_model.v (nonexistent)
+++ tags/start/verilog/wb_mast_model.v (revision 3)
@@ -0,0 +1,734 @@
+/////////////////////////////////////////////////////////////////////
+//// ////
+//// WISHBONE Master Model ////
+//// ////
+//// ////
+//// Author: Rudolf Usselmann ////
+//// rudi@asics.ws ////
+//// ////
+/////////////////////////////////////////////////////////////////////
+//// ////
+//// Copyright (C) 2001 Rudolf Usselmann ////
+//// rudi@asics.ws ////
+//// ////
+//// This source file may be used and distributed without ////
+//// restriction provided that this copyright statement is not ////
+//// removed from the file and that any derivative work contains ////
+//// the original copyright notice and the associated disclaimer.////
+//// ////
+//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ////
+//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ////
+//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ////
+//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ////
+//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
+//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ////
+//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ////
+//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ////
+//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ////
+//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
+//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ////
+//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ////
+//// POSSIBILITY OF SUCH DAMAGE. ////
+//// ////
+/////////////////////////////////////////////////////////////////////
+
+// CVS Log
+//
+// $Id: wb_mast_model.v,v 1.1.1.1 2001-07-26 08:22:36 rudi Exp $
+//
+// $Date: 2001-07-26 08:22:36 $
+// $Revision: 1.1.1.1 $
+// $Author: rudi $
+// $Locker: $
+// $State: Exp $
+//
+// Change History:
+// $Log: not supported by cvs2svn $
+//
+//
+//
+//
+//
+
+/*
+
+task mem_fill;
+
+- Fills local burst read (rd_buf[]) and write(wr_buf[]) buffers with random values.
+
+
+task wb_wr1( 32 bit address, 4 bit byte select, 32 bit write data);
+
+- Performs a single WISHBONE write
+
+
+task wb_wr4( 32 bit address, 4 bit byte select, integer delay,
+ 32 bit data 1, 32 bit data 2, 32 bit data 3, 32 bit data 4);
+
+- Performs 4 consecutive WISHBONE writes
+- Strobe is deasserted between writes for 'delay' number of cycles
+ (This simulates wait state insertion ...)
+
+
+task wb_wr_mult( 32 bit address, 4 bit byte select, integer delay,
+ integer count);
+
+- Simular to wb_wr4, except it pwrforms "count" number of write cycles.
+ The data is taken from the internal wr_bub[] memory.
+- Strobe is deasserted between writes for 'delay' number of cycles
+ (This simulates wait state insertion ...)
+
+
+task wb_rmw( 32 bit address, 4 bit byte select, integer delay,
+ integer rcount, integer wcount);
+
+- This task performs "rcount" read cycles, followed by wcount write cycles.
+- read data is placed in to the internal rd_buf[] memory, write data is
+ taken from the internal wr_buf[] memory.
+- Strobe is deasserted between writes for 'delay' number of cycles
+ (This simulates wait state insertion ...)
+
+task wb_wmr( 32 bit address, 4 bit byte select, integer delay,
+ integer rcount, integer wcount);
+
+- This task performs "wcount" write cycles, followed by "rcount" read cycles.
+- read data is placed in to the internal rd_buf[] memory, write data is
+ taken from the internal wr_buf[] memory.
+- Strobe is deasserted between writes for 'delay' number of cycles
+ (This simulates wait state insertion ...)
+
+task wb_rd1( 32 bit address, 4 bit byte select, 32 bit read data);
+
+- Performs a single WISHBONE write
+
+
+task wb_rd4( 32 bit address, 4 bit byte select, integer delay,
+ 32 bit data 1, 32 bit data 2, 32 bit data 3, 32 bit data 4);
+
+- Performs 4 consecutive WISHBONE reads
+- Strobe is deasserted between reads for 'delay' number of cycles
+ (This simulates wait state insertion ...)
+
+
+task wb_rd_mult( 32 bit address, 4 bit byte select, integer delay,
+ integer count);
+
+- Simular to wb_rd4, except it pwrforms "count" number of read cycles.
+ The data is read in to the internal rd_buf[] memory.
+- Strobe is deasserted between reads for 'delay' number of cycles
+ (This simulates wait state insertion ...)
+
+*/
+
+
+`include "wb_model_defines.v"
+
+module wb_mast(clk, rst, adr, din, dout, cyc, stb, sel, we, ack, err, rty);
+
+input clk, rst;
+output [31:0] adr;
+input [31:0] din;
+output [31:0] dout;
+output cyc, stb;
+output [3:0] sel;
+output we;
+input ack, err, rty;
+
+////////////////////////////////////////////////////////////////////
+//
+// Local Wires
+//
+
+parameter mem_size = 4096;
+
+reg [31:0] adr;
+reg [31:0] dout;
+reg cyc, stb;
+reg [3:0] sel;
+reg we;
+
+reg [31:0] rd_mem[mem_size:0];
+reg [31:0] wr_mem[mem_size:0];
+integer rd_cnt;
+integer wr_cnt;
+
+////////////////////////////////////////////////////////////////////
+//
+// Memory Logic
+//
+
+initial
+ begin
+ adr = 32'hxxxx_xxxx;
+ dout = 32'hxxxx_xxxx;
+ cyc = 0;
+ stb = 0;
+ sel = 4'hx;
+ we = 1'hx;
+ rd_cnt = 0;
+ wr_cnt = 0;
+ #1;
+ $display("\nINFO: WISHBONE MASTER MODEL INSTANTIATED (%m)\n");
+ end
+
+
+task mem_fill;
+
+integer n;
+begin
+rd_cnt = 0;
+wr_cnt = 0;
+for(n=0;n
/tags/start/verilog/wb_slv_model.v
0,0 → 1,168
///////////////////////////////////////////////////////////////////// |
//// //// |
//// WISHBONE Slave Model //// |
//// //// |
//// //// |
//// Author: Rudolf Usselmann //// |
//// rudi@asics.ws //// |
//// //// |
//// //// |
///////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2001 Rudolf Usselmann //// |
//// rudi@asics.ws //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer.//// |
//// //// |
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY //// |
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED //// |
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS //// |
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR //// |
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, //// |
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES //// |
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE //// |
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR //// |
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF //// |
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT //// |
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT //// |
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE //// |
//// POSSIBILITY OF SUCH DAMAGE. //// |
//// //// |
///////////////////////////////////////////////////////////////////// |
|
// CVS Log |
// |
// $Id: wb_slv_model.v,v 1.1.1.1 2001-07-26 08:22:39 rudi Exp $ |
// |
// $Date: 2001-07-26 08:22:39 $ |
// $Revision: 1.1.1.1 $ |
// $Author: rudi $ |
// $Locker: $ |
// $State: Exp $ |
// |
// Change History: |
// $Log: not supported by cvs2svn $ |
// |
// |
// |
|
/* USAGE |
|
wb_slv #(mem_addr_bus_width) |
<unit #>(clk, rst, adr, din, dout, cyc, stb, sel, we, ack, err, rty); |
|
The parameter "mem_addr_bus_width" indicates the size of the memory by |
specifiying the number of address lines to the memory. |
|
task fill_mem(mode); |
- This task initializes the internal memory. |
If mode is 0, the memory is initialized to { ~address[15:0], address[15:0] }; |
If mode is 1, the memory is initialized to random values. |
|
|
The internal register "delay" specifies how fast ack is generated by the slave. |
A value of 0 indicated immediatly, a value of 1 1 cycle delay etc. |
It can be accesset by: |
<wb_slv_unit_id>.delay = 5 bit value |
|
*/ |
|
`include "wb_model_defines.v" |
|
module wb_slv(clk, rst, adr, din, dout, cyc, stb, sel, we, ack, err, rty); |
|
input clk, rst; |
input [31:0] adr, din; |
output [31:0] dout; |
input cyc, stb; |
input [3:0] sel; |
input we; |
output ack, err, rty; |
|
//////////////////////////////////////////////////////////////////// |
// |
// Local Wires |
// |
|
parameter mem_size = 13; |
parameter sz = (1<<mem_size)-1; |
|
reg [31:0] mem[sz:0]; |
wire mem_re, mem_we; |
wire [31:0] tmp; |
reg [31:0] dout, tmp2; |
|
reg err, rty; |
reg [31:0] del_ack; |
reg [5:0] delay; |
|
//////////////////////////////////////////////////////////////////// |
// |
// Memory Logic |
// |
|
initial |
begin |
delay = 0; |
err = 0; |
rty = 0; |
#2; |
$display("\nINFO: WISHBONE MEMORY MODEL INSTANTIATED (%m)"); |
$display(" Memory Size %0d address lines %0d words\n", |
mem_size, sz+1); |
end |
|
assign mem_re = cyc & stb & !we; |
assign mem_we = cyc & stb & we; |
|
assign tmp = mem[adr[mem_size+1:2]]; |
|
always @(sel or tmp or mem_re or ack) |
if(mem_re & ack) |
begin |
dout[31:24] <= #1 sel[3] ? tmp[31:24] : 8'hxx; |
dout[23:16] <= #1 sel[2] ? tmp[23:16] : 8'hxx; |
dout[15:08] <= #1 sel[1] ? tmp[15:08] : 8'hxx; |
dout[07:00] <= #1 sel[0] ? tmp[07:00] : 8'hxx; |
end |
else dout <= #1 32'hzzzz_zzzz; |
|
|
always @(sel or tmp or din) |
begin |
tmp2[31:24] = !sel[3] ? tmp[31:24] : din[31:24]; |
tmp2[23:16] = !sel[2] ? tmp[23:16] : din[23:16]; |
tmp2[15:08] = !sel[1] ? tmp[15:08] : din[15:08]; |
tmp2[07:00] = !sel[0] ? tmp[07:00] : din[07:00]; |
end |
|
always @(posedge clk) |
if(mem_we) mem[adr[mem_size+1:2]] <= #1 tmp2; |
|
always @(posedge clk) |
del_ack = ack ? 0 : {del_ack[30:0], (mem_re | mem_we)}; |
|
assign #3 ack = cyc & ((delay==0) ? (mem_re | mem_we) : del_ack[delay-1]); |
|
task fill_mem; |
input mode; |
|
integer n, mode; |
|
begin |
|
for(n=0;n<(sz+1);n=n+1) |
begin |
case(mode) |
0: mem[n] = { ~n[15:0], n[15:0] }; |
1: mem[n] = $random; |
endcase |
end |
|
end |
endtask |
|
endmodule |
/tags/start/verilog/wb_model_defines.v
0,0 → 1,52
///////////////////////////////////////////////////////////////////// |
//// //// |
//// WISHBONE Model Definitions //// |
//// //// |
//// //// |
//// Author: Rudolf Usselmann //// |
//// rudi@asics.ws //// |
//// //// |
//// //// |
///////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2001 Rudolf Usselmann //// |
//// rudi@asics.ws //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer.//// |
//// //// |
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY //// |
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED //// |
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS //// |
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR //// |
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, //// |
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES //// |
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE //// |
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR //// |
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF //// |
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT //// |
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT //// |
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE //// |
//// POSSIBILITY OF SUCH DAMAGE. //// |
//// //// |
///////////////////////////////////////////////////////////////////// |
|
// CVS Log |
// |
// $Id: wb_model_defines.v,v 1.1.1.1 2001-07-26 08:22:39 rudi Exp $ |
// |
// $Date: 2001-07-26 08:22:39 $ |
// $Revision: 1.1.1.1 $ |
// $Author: rudi $ |
// $Locker: $ |
// $State: Exp $ |
// |
// Change History: |
// $Log: not supported by cvs2svn $ |
// |
// |
// |
|
`timescale 1ns / 10ps |