OpenCores
URL https://opencores.org/ocsvn/suslik/suslik/trunk

Subversion Repositories suslik

[/] [suslik/] [trunk/] [rtl/] [sim_test.v] - Blame information for rev 9

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 gorand2
`timescale 1 ns / 100 ps
2
 
3
module testram(input clk,input we, input [31:0] addrA, output reg [511:0] dataA,input [511:0] dataW);
4
  reg [31:0] ram0 [32767:0];
5
  always @(posedge clk)
6
    begin
7
      dataA<=
8
      {
9
        ram0[{addrA[16:6],4'd15}],
10
        ram0[{addrA[16:6],4'd14}],
11
        ram0[{addrA[16:6],4'd13}],
12
        ram0[{addrA[16:6],4'd12}],
13
        ram0[{addrA[16:6],4'd11}],
14
        ram0[{addrA[16:6],4'd10}],
15
        ram0[{addrA[16:6],4'd9}],
16
        ram0[{addrA[16:6],4'd8}],
17
        ram0[{addrA[16:6],4'd7}],
18
        ram0[{addrA[16:6],4'd6}],
19
        ram0[{addrA[16:6],4'd5}],
20
        ram0[{addrA[16:6],4'd4}],
21
        ram0[{addrA[16:6],4'd3}],
22
        ram0[{addrA[16:6],4'd2}],
23
        ram0[{addrA[16:6],4'd1}],
24
        ram0[{addrA[16:6],4'd0}]
25
      };
26
      if (we)
27
        begin
28
          ram0[{addrA[16:6],4'd0}]<=dataW[31:0];
29
          ram0[{addrA[16:6],4'd1}]<=dataW[63:32];
30
          ram0[{addrA[16:6],4'd2}]<=dataW[95:64];
31
          ram0[{addrA[16:6],4'd3}]<=dataW[127:96];
32
          ram0[{addrA[16:6],4'd4}]<=dataW[159:128];
33
          ram0[{addrA[16:6],4'd5}]<=dataW[191:160];
34
          ram0[{addrA[16:6],4'd6}]<=dataW[223:192];
35
          ram0[{addrA[16:6],4'd7}]<=dataW[255:224];
36
          ram0[{addrA[16:6],4'd8}]<=dataW[287:256];
37
          ram0[{addrA[16:6],4'd9}]<=dataW[319:288];
38
          ram0[{addrA[16:6],4'd10}]<=dataW[351:320];
39
          ram0[{addrA[16:6],4'd11}]<=dataW[383:352];
40
          ram0[{addrA[16:6],4'd12}]<=dataW[415:384];
41
          ram0[{addrA[16:6],4'd13}]<=dataW[447:416];
42
          ram0[{addrA[16:6],4'd14}]<=dataW[479:448];
43
          ram0[{addrA[16:6],4'd15}]<=dataW[511:480];
44
        end
45
 
46
    end
47
endmodule
48
 
49
module cpu2r6test();
50
 
51
  reg clk=0;
52
  wire busEnRead=1;
53
  wire busEnWrite=1;
54
  wire busRead;
55
  wire busWrite;
56
  wire [31:0] busAddr;
57
  wire [511:0] busInput;
58
  wire [511:0] ramDataA;
59
  wire [511:0] ramDataW;
60
  reg [511:0] dataW_reg;
61
  reg we_reg=0;
62
  wire we;
63
  reg [31:0] addr_reg;
64
  reg busRdy=0;
65
 
66
  wire [31:0] ioBusAddr;
67
  wire [1:0] ioBusSize;
68
  wire [31:0] ioBusOut;
69
  wire [31:0] ioBusIn;
70
  reg ioBusRdy=0;
71
  wire ioBusWr;
72
  wire ioBusRd;
73
  wire [3:0] dummy;
74
 
75
  cpu2r6 mycpu2(clk,busEnRead,busEnWrite,busRdy,busRead,busWrite,busAddr,busInput,ramDataW,
76
                ioBusAddr,ioBusSize,ioBusOut,ioBusIn,ioBusRdy,ioBusWr,ioBusRd,dummy);
77
  testram ram0(clk,we,busAddr,ramDataA,ramDataW);
78
 
79
  assign busInput=(we_reg && (busAddr==addr_reg)) ? dataW_reg : ramDataA;
80
  assign we=busWrite;
81
 
82
  always @(posedge clk)
83
    begin
84
      ioBusRdy<=ioBusWr || ioBusRd;
85
      we_reg<=we;
86
      dataW_reg<=ramDataW;
87
      addr_reg<=busAddr;
88
      busRdy<=busRead;
89
      if (ioBusWr) $display("out addr %h,data %h",ioBusAddr,ioBusOut);
90
      if (ioBusRd) $display("in addr %h",ioBusAddr);
91
    end
92
 
93
  always
94
    #100 clk<=!clk;
95
 
96
  initial
97
    begin
98
      $readmemh("testmem6.hex",ram0.ram0);
99
      $monitor("r2=0x%h",mycpu2.regf0.ram0.regs[2]);
100
    end
101
 
102
endmodule
103
 
104
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.