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

Subversion Repositories uart2bus

[/] [uart2bus/] [trunk/] [verilog/] [bench/] [reg_file_model.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 motilito
//---------------------------------------------------------------------------------------
2
// register file model as a simple memory 
3
//
4
//---------------------------------------------------------------------------------------
5
 
6
`include "timescale.v"
7
 
8
module reg_file_model
9
(
10
        // global signals 
11
        clock, reset,
12
        // internal bus to register file 
13
        int_address, int_wr_data, int_write,
14
        int_rd_data, int_read
15
);
16
//---------------------------------------------------------------------------------------
17
// modules inputs and outputs 
18
input                   clock;                  // global clock input 
19
input                   reset;                  // global reset input 
20
input   [7:0]    int_address;    // address bus to register file 
21
input   [7:0]    int_wr_data;    // write data to register file 
22
input                   int_write;              // write control to register file 
23
input                   int_read;               // read control to register file 
24
output  [7:0]    int_rd_data;    // data read from register file 
25
 
26
// registered outputs
27
reg [7:0] int_rd_data;
28
 
29
// internal signal  
30
reg [7:0] reg_file [0:255];   // 256 of 8 bit registers 
31
 
32
//---------------------------------------------------------------------------------------
33
// internal tasks 
34
// clear memory 
35
task clear_reg_file;
36
reg [8:0] regfile_adr;
37
begin
38
   for (regfile_adr = 9'h00; regfile_adr < 9'h80; regfile_adr = regfile_adr + 1)
39
   begin
40
          reg_file[regfile_adr] = 0;
41
   end
42
end
43
endtask
44
 
45
//---------------------------------------------------------------------------------------
46
// module implementation 
47
// register file write 
48
always @ (posedge clock or posedge reset)
49
begin
50
        if (reset)
51
                clear_reg_file;
52
        else if (int_write)
53
                reg_file[int_address] <= int_wr_data;
54
end
55
 
56
// register file read 
57
always @ (posedge clock or posedge reset)
58
begin
59
        if (reset)
60
                int_rd_data <= 8'h0;
61
        else if (int_read)
62
                int_rd_data <= reg_file[int_address];
63
end
64
 
65
endmodule
66
//---------------------------------------------------------------------------------------
67
//                                              Th.. Th.. Th.. Thats all folks !!!
68
//---------------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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