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

Subversion Repositories sd_mmc_emulator

[/] [sd_mmc_emulator/] [trunk/] [rtl/] [arty_main.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jclaytons
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company: Ampleon
4
// Engineer: John Clayton
5
// 
6
// Create Date: 05/20/2016
7
// Design Name: MMC Tester
8
// Module Name: arty_main
9
// Project Name: Sango X7
10
// Target Devices: XC7A35T
11
// Tool Versions: 
12
// Description: 10ns CLK
13
// 
14
// Dependencies: 
15
// 
16
// Revision:
17
// Revision 0.01 - File Created
18
// Additional Comments:
19
// 
20
//////////////////////////////////////////////////////////////////////////////////
21
 
22
`define CLOCK_FREQ 100000000
23
 
24
module top(
25
  input         CLK,
26
  input         ck_rst,
27
  input  [ 3:0] SW,
28
  input  [ 3:0] BTN,
29
  input         UART_CMD_i,
30
  output        UART_RSP_o,
31
  output        RGB0_Blue,
32
  output        RGB0_Green,
33
  output        RGB0_Red,
34
  output        RGB1_Blue,
35
  output        RGB1_Green,
36
  output        RGB1_Red,
37
  output        RGB2_Blue,
38
  output        RGB2_Green,
39
  output        RGB2_Red,
40
  output        RGB3_Blue,
41
  output        RGB3_Green,
42
  output        RGB3_Red,
43
  output [ 3:0] LED,
44
  inout  [ 7:0] ja,
45
  inout  [ 7:0] jb,
46
  inout  [ 7:0] jc,
47
  inout  [ 7:0] jd
48
);
49
 
50
//------------------------------------------------------------------------
51
// Local signals
52
reg  [39:0] count1;
53
wire        sys_clk;
54
wire        sys_rst_n;
55
wire [15:0] led_l;
56
 
57
// MMC tester
58
wire        mmc_clk;
59
wire        mmc_clk_oe;
60
wire        mmc_cmd;
61
wire        mmc_cmd_oe;
62
wire        mmc_cmd_zzz;
63
wire        mmc_cmd_choice;
64
wire  [7:0] mmc_dat;
65
wire  [7:0] mmc_dat_zzz;
66
wire  [7:0] mmc_dat_choice1;
67
wire  [7:0] mmc_dat_choice2;
68
reg   [7:0] mmc_dat_choice3;
69
wire        mmc_od_mode;
70
wire        mmc_dat_oe;
71
wire  [1:0] mmc_dat_siz;
72
wire  [7:0] switch;
73
wire        mmc_tlm;
74
wire        syscon_rsp;
75
 
76
// MMC card I/O proxy signals
77
// (They are mapped to jb and jc ports)
78
wire        MMC_CLK_io;
79
wire        MMC_CMD_io;
80
wire  [7:0] MMC_DAT_io;
81
wire        MMC_CLK_i;
82
wire        MMC_CMD_i;
83
wire  [7:0] MMC_DAT_i;
84
 
85
//------------------------------------------------------------------------
86
// Start of logic
87
 
88
assign sys_clk = CLK;
89
assign sys_rst_n = ck_rst;
90
 
91
// Create a counter to display on the LEDs
92
always @(posedge sys_clk)
93
  if (!sys_rst_n) begin
94
    count1 <= 0;
95
  end
96
  else begin
97
    count1 <= count1+1;
98
  end
99
 
100
// Assign outputs
101
assign RGB0_Blue  = SW[3]?count1[39]:led_l[15];
102
assign RGB0_Green = SW[3]?count1[38]:led_l[14];
103
assign RGB0_Red   = SW[3]?count1[37]:led_l[13];
104
assign RGB1_Blue  = SW[3]?count1[36]:led_l[12];
105
assign RGB1_Green = SW[3]?count1[35]:led_l[11];
106
assign RGB1_Red   = SW[3]?count1[34]:led_l[10];
107
assign RGB2_Blue  = SW[3]?count1[33]:led_l[9];
108
assign RGB2_Green = SW[3]?count1[32]:led_l[8];
109
assign RGB2_Red   = SW[3]?count1[31]:led_l[7];
110
assign RGB3_Blue  = SW[3]?count1[30]:led_l[6];
111
assign RGB3_Green = SW[3]?count1[29]:led_l[5];
112
assign RGB3_Red   = SW[3]?count1[28]:led_l[4];
113
assign LED        = SW[3]?(count1[27:24] ^ SW):led_l[3:0];
114
 
115
  mmc_tester #(
116
    .SYS_CLK_RATE         (100000000.0),    // Fast I/O read/write (app specific)
117
    .SYS_LEDS             (16),
118
    .SYS_SWITCHES         (8),
119
    .EXT_CSD_INIT_FILE    ("ext_csd_init.txt"), // Initial contents of EXT_CSD
120
    .HOST_RAM_ADR_BITS    (14), // Determines amount of BRAM in MMC host
121
    .MMC_FIFO_DEPTH       (2048),
122
    .MMC_FILL_LEVEL_BITS  (14),
123
    .MMC_RAM_ADR_BITS     (17)
124
  ) mmc_tester_0 (
125
 
126
    // Asynchronous reset
127
    .sys_rst_n     (sys_rst_n),
128
    .sys_clk       (sys_clk),
129
 
130
    // Asynchronous serial interface
131
    .cmd_i         (UART_CMD_i),
132
    .resp_o        (syscon_rsp),
133
 
134
    // Board related
135
    .switch_i      (switch),
136
    .led_o         (led_l),
137
 
138
    // Interface for SD/MMC traffic logging
139
    // via asynchronous serial transmission
140
    .tlm_send_i    (SW[3]),
141
    .tlm_o         (mmc_tlm),
142
 
143
    // Tester Function Enables
144
    .slave_en_i    (SW[2]),
145
    .host_en_i     (SW[1]),
146
 
147
    // SD/MMC card signals
148
    .mmc_clk_i     (MMC_CLK_i),
149
    .mmc_clk_o     (mmc_clk),
150
    .mmc_clk_oe_o  (mmc_clk_oe),
151
    .mmc_cmd_i     (MMC_CMD_i),
152
    .mmc_cmd_o     (mmc_cmd),
153
    .mmc_cmd_oe_o  (mmc_cmd_oe),
154
    .mmc_dat_i     (MMC_DAT_i),
155
    .mmc_dat_o     (mmc_dat),
156
    .mmc_dat_oe_o  (mmc_dat_oe),
157
    .mmc_od_mode_o (mmc_od_mode),  // open drain mode, applies to sd_cmd_o and sd_dat_o
158
    .mmc_dat_siz_o (mmc_dat_siz)
159
 
160
  );
161
  assign switch = {BTN, SW};
162
 
163
  assign UART_RSP_o = SW[3]?mmc_tlm:syscon_rsp;
164
 
165
 
166
  // Implement MMC card tri-state drivers at the top level
167
    // Drive the clock output when needed
168
  assign MMC_CLK_io = mmc_clk_oe?mmc_clk:1'bZ;
169
    // Select which data vector to use
170
  assign mmc_dat_choice1 = mmc_od_mode?mmc_dat_zzz:mmc_dat;
171
  assign mmc_dat_choice2 = mmc_dat_oe?mmc_dat_choice1:8'bZ;
172
    // Create mmc command signals
173
  assign mmc_cmd_zzz    = mmc_cmd?1'bZ:1'b0;
174
  assign mmc_cmd_choice = mmc_od_mode?mmc_cmd_zzz:mmc_cmd;
175
  assign MMC_CMD_io = mmc_cmd_oe?mmc_cmd_choice:1'bZ;
176
    // Create "open drain" data vector
177
  genvar j;
178
  for(j=0;j<8;j=j+1) begin
179
    assign mmc_dat_zzz[j] = mmc_dat[j]?1'bZ:1'b0;
180
  end
181
    // Select which data vector to use
182
  assign mmc_dat_choice1 = mmc_od_mode?mmc_dat_zzz:mmc_dat;
183
  assign mmc_dat_choice2 = mmc_dat_oe?mmc_dat_choice1:8'bZ;
184
    // Use always block for readability
185
  always @(mmc_dat_siz, mmc_dat_choice2)
186
         if (mmc_dat_siz==0) mmc_dat_choice3 <= {7'bZ,mmc_dat_choice2[0]};
187
    else if (mmc_dat_siz==1) mmc_dat_choice3 <= {4'bZ,mmc_dat_choice2[3:0]};
188
    else                     mmc_dat_choice3 <= mmc_dat_choice2;
189
 
190
  assign MMC_DAT_io = mmc_dat_choice3;
191
 
192
  // Map the MMC I/O proxies to actual I/O signals
193
  assign jb[6] = MMC_CLK_io;
194
  assign jb[2] = MMC_CMD_io;
195
  assign jc[4] = MMC_DAT_io[0];
196
  assign jc[0] = MMC_DAT_io[1];
197
  assign jc[7] = MMC_DAT_io[2];
198
  assign jc[3] = MMC_DAT_io[3];
199
  assign jc[6] = MMC_DAT_io[4];
200
  assign jc[2] = MMC_DAT_io[5];
201
  assign jc[5] = MMC_DAT_io[6];
202
  assign jc[1] = MMC_DAT_io[7];
203
 
204
  // Map the MMC input proxies to actual I/O signals
205
  assign MMC_CLK_i = jb[6];
206
  assign MMC_CMD_i = jb[2];
207
  assign MMC_DAT_i = {jc[1], jc[5], jc[2], jc[6], jc[3], jc[7], jc[0], jc[4]};
208
 
209
endmodule

powered by: WebSVN 2.1.0

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