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

Subversion Repositories versatile_io

[/] [versatile_io/] [trunk/] [rtl/] [verilog/] [top/] [versatile_io_top.v] - Blame information for rev 15

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

Line No. Rev Author Line
1 2 unneback
module versatile_io (
2
    input [31:0] wbs_dat_i,
3
    input [31:0] wbs_adr_i,
4
    input [3:0] wbs_sel_i,
5
    input wbs_we_i, wbs_stb_i, wbs_cyc_i,
6
    output [31:0] wbs_dat_o,
7 4 unneback
    output wbs_ack_o,
8 2 unneback
`ifdef B4
9
    output wbs_stall_o,
10
`endif
11
`include "versatile_io_module.v"
12
`ifdef UART0
13
    output uart0_irq,
14
`endif
15
    input wbs_clk, wbs_rst,
16
    input clk, rst
17
);
18
 
19 4 unneback
`ifdef UART0
20
parameter uart0_mem_map_hi = `UART0_MEM_MAP_HI;
21
parameter uart0_mem_map_lo = `UART0_MEM_MAP_LO;
22
parameter [31:0] uart0_base_adr = `UART0_BASE_ADR;
23
`endif
24 2 unneback
function [7:0] tobyte;
25
input [3:0] sel_i;
26
input [31:0] dat_i;
27
begin
28
    tobyte = ({8{sel_i[3]}} & dat_i[31:24]) | ({8{sel_i[2]}} & dat_i[23:16]) | ({8{sel_i[1]}} & dat_i[15:8]) | ({8{sel_i[0]}} & dat_i[7:0]);
29 4 unneback
end
30 2 unneback
endfunction
31
 
32
function [31:0] toword;
33
input [7:0] dat_i;
34
begin
35
    toword = {4{dat_i}};
36 4 unneback
end
37 2 unneback
endfunction
38
 
39
function [31:0] mask;
40
input [31:0] dat_i;
41
input sel;
42
begin
43
    mask = {32{sel}} & dat_i;
44
end
45
endfunction
46
 
47
`ifdef UART0
48 4 unneback
wire uart0_cs;
49
assign uart0_cs = wbs_adr_i[uart0_mem_map_hi:uart0_mem_map_lo] == uart0_base_adr[uart0_mem_map_hi:uart0_mem_map_lo];
50 2 unneback
wire [7:0] uart0_temp;
51
wire uart0_ack_o;
52 14 unneback
/*
53 2 unneback
uart_top uart0  (
54 4 unneback
    .wb_clk_i(wbs_clk), .wb_rst_i(wbs_rst),
55 2 unneback
    // Wishbone signals
56
    .wb_adr_i(wbs_adr_i[2:0]), .wb_dat_i(tobyte(wbs_sel_i,wbs_dat_i)), .wb_dat_o(uart0_temp), .wb_we_i(wbs_we_i), .wb_stb_i(wbs_stb_i), .wb_cyc_i(wbs_cyc_i & uart0_cs), .wb_ack_o(uart0_ack_o), .wb_sel_i(4'b0),
57
    .int_o(uart0_irq), // interrupt request
58
    // UART     signals
59
    // serial input/output
60 14 unneback
    .stx_pad_o(uart0_tx_pad_o), .srx_pad_i(uart0_rx_pad_i),
61 2 unneback
    // modem signals
62
    .rts_pad_o(), .cts_pad_i(1'b0), .dtr_pad_o(), .dsr_pad_i(1'b0), .ri_pad_i(1'b0), .dcd_pad_i(1'b0) );
63 14 unneback
*/
64
uart16750_wb uart0(
65
    // UART signals
66
    .rx(uart0_rx_pad_i),
67
    .tx(uart0_tx_pad_o),
68
    .int(uart0_irq),
69
    // wishbone slave
70
    .wbs_dat_i(tobyte(wbs_sel_i,wbs_dat_i)),
71
    .wbs_adr_i(wbs_adr_i[2:0]),
72
    .wbs_we_i(wbs_we_i),
73
    .wbs_cyc_i(wbs_cyc_i & uart0_cs),
74
    .wbs_stb_i(wbs_stb_i),
75
    .wbs_dat_o(uart0_temp),
76
    .wbs_ack_o(uart0_ack_o),
77
    .wb_clk_i(wbs_clk),
78
    .wb_rst_i(wbs_rst) );
79 2 unneback
assign uart0_dat_o = mask( toword(uart0_temp), uart0_ack_o);
80
`else
81
assign uart0_dat_o = 32'h0;
82
assign uart0_ack_o = 1'b0;
83
`endif
84
 
85
assign wbs_dat_o = uart0_dat_o;
86
assign wbs_ack_o = uart0_ack_o;
87
`ifdef WB4
88
assign wbs_stall_o = 1'b0;
89
`endif
90
 
91
endmodule

powered by: WebSVN 2.1.0

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