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

Subversion Repositories tv80

[/] [tv80/] [trunk/] [rtl/] [simple_gmii/] [simple_gmii_regs.v] - Blame information for rev 86

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

Line No. Rev Author Line
1 65 ghutchis
module simple_gmii_regs (
2
clk,reset,addr,wr_data,rd_data,doe,rd_n,wr_n,iorq_n,status_set,status_msk,control,control_clr,rx_len0,rx_len1,rx_data,rx_data_stb,tx_data,tx_data_stb,config,int_n);
3
input clk;
4
input reset;
5
input [15:0] addr;
6
input [7:0] wr_data;
7
output [7:0] rd_data;
8
output doe;
9
input rd_n;
10
input wr_n;
11
input iorq_n;
12
input [1:0] status_set;
13
output [1:0] status_msk;
14
output control;
15
input control_clr;
16
input [7:0] rx_len0;
17
input [7:0] rx_len1;
18
input [7:0] rx_data;
19
output rx_data_stb;
20
output [7:0] tx_data;
21
output tx_data_stb;
22
output config;
23
output int_n;
24
reg [7:0] rd_data;
25
reg block_select;
26
reg doe;
27
reg status_rd_sel;
28
reg [1:0] status;
29
reg status_wr_sel;
30
reg status_int;
31
reg [1:0] status_msk;
32
reg status_msk_rd_sel;
33
reg status_msk_wr_sel;
34
reg control;
35
reg control_rd_sel;
36
reg control_wr_sel;
37
reg rx_len0_rd_sel;
38
reg rx_len1_rd_sel;
39
reg rx_data_rd_sel;
40
reg rx_data_stb;
41
reg [7:0] tx_data;
42
reg tx_data_rd_sel;
43
reg tx_data_wr_sel;
44
reg tx_data_stb;
45
reg config;
46
reg config_rd_sel;
47
reg config_wr_sel;
48
reg int_n;
49
reg [7:0] int_vec;
50
always @*
51
  begin
52
    block_select = (addr[7:3] == 1) & !iorq_n;
53
    status_rd_sel = block_select & (addr[2:0] == 0) & !rd_n;
54
    status_wr_sel = block_select & (addr[2:0] == 0) & !wr_n;
55
    status_msk_rd_sel = block_select & (addr[2:0] == 1) & !rd_n;
56
    status_msk_wr_sel = block_select & (addr[2:0] == 1) & !wr_n;
57
    control_rd_sel = block_select & (addr[2:0] == 2) & !rd_n;
58
    control_wr_sel = block_select & (addr[2:0] == 2) & !wr_n;
59
    rx_len0_rd_sel = block_select & (addr[2:0] == 3) & !rd_n;
60
    rx_len1_rd_sel = block_select & (addr[2:0] == 4) & !rd_n;
61
    rx_data_rd_sel = block_select & (addr[2:0] == 5) & !rd_n;
62
    tx_data_rd_sel = block_select & (addr[2:0] == 6) & !rd_n;
63
    tx_data_wr_sel = block_select & (addr[2:0] == 6) & !wr_n;
64
    config_rd_sel = block_select & (addr[2:0] == 7) & !rd_n;
65
    config_wr_sel = block_select & (addr[2:0] == 7) & !wr_n;
66
  end
67
always @*
68
  begin
69
    case (1'b1)
70
      status_int : int_vec = 207;
71
      default : int_vec = 8'bx;
72
    endcase
73
    case (1'b1)
74
      status_rd_sel : rd_data = status;
75
      status_msk_rd_sel : rd_data = status_msk;
76
      control_rd_sel : rd_data = control;
77
      rx_len0_rd_sel : rd_data = rx_len0;
78
      rx_len1_rd_sel : rd_data = rx_len1;
79
      rx_data_rd_sel : rd_data = rx_data;
80
      tx_data_rd_sel : rd_data = tx_data;
81
      config_rd_sel : rd_data = config;
82
      default : rd_data = int_vec;
83
    endcase
84
    doe = status_rd_sel | status_msk_rd_sel | control_rd_sel | rx_len0_rd_sel | rx_len1_rd_sel | rx_data_rd_sel | tx_data_rd_sel | config_rd_sel;
85
  end
86
always @*
87
  begin
88
    int_n = ~(status_int);
89
  end
90
// register: status
91
always @(posedge clk)
92
  begin
93
    if (reset) status <= 0;
94
    else status <= (status_set | status) & ~( {2{status_wr_sel}} & wr_data);
95
    if (reset) status_int <= 0;
96
    else status_int <= |(status & ~status_msk);
97
  end
98
// register: status_msk
99
always @(posedge clk)
100
  begin
101
    if (reset) status_msk <= 0;
102
    else if (status_msk_wr_sel) status_msk <= wr_data;
103
  end
104
// register: control
105
always @(posedge clk)
106
  begin
107
    if (reset) control <= 0;
108
    else control <= ( ({1{control_wr_sel}} & wr_data) | control) & ~(control_clr);
109
  end
110
// register: rx_data
111
always @(posedge clk)
112
  begin
113
    if (reset) rx_data_stb <= 0;
114
    else if (rx_data_rd_sel) rx_data_stb <= 1;
115
    else rx_data_stb <= 0;
116
  end
117
always @(posedge clk)
118
  begin
119
    if (reset) tx_data <= 0;
120
    else if (tx_data_wr_sel) tx_data <= wr_data;
121
    if (reset) tx_data_stb <= 0;
122
    else if (tx_data_wr_sel) tx_data_stb <= 1;
123
    else tx_data_stb <= 0;
124
  end
125
// register: config
126
always @(posedge clk)
127
  begin
128
    if (reset) config <= 0;
129
    else if (config_wr_sel) config <= wr_data;
130
  end
131
endmodule

powered by: WebSVN 2.1.0

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