1 |
2 |
alfik |
/*
|
2 |
|
|
* Copyright 2010, Aleksander Osman, alfik@poczta.fm. All rights reserved.
|
3 |
|
|
*
|
4 |
|
|
* Redistribution and use in source and binary forms, with or without modification, are
|
5 |
|
|
* permitted provided that the following conditions are met:
|
6 |
|
|
*
|
7 |
|
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
8 |
|
|
* conditions and the following disclaimer.
|
9 |
|
|
*
|
10 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
11 |
|
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
12 |
|
|
* provided with the distribution.
|
13 |
|
|
*
|
14 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
15 |
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
16 |
|
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
|
17 |
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
18 |
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
19 |
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
20 |
|
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
21 |
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
22 |
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
23 |
|
|
*/
|
24 |
|
|
|
25 |
|
|
/*! \file
|
26 |
|
|
* \brief OCS serial port implementation with WISHBONE slave interface. [functionality not implemented]
|
27 |
|
|
*/
|
28 |
|
|
|
29 |
|
|
/*! \brief \copybrief ocs_serial.v
|
30 |
|
|
|
31 |
|
|
List of serial registers:
|
32 |
|
|
\verbatim
|
33 |
|
|
Not implemented:
|
34 |
|
|
SERDATR *018 R P Serial port data and status read read implemented here
|
35 |
|
|
[DSKBYTR *01A R P Disk data byte and status read read implemented here]
|
36 |
|
|
|
37 |
|
|
SERDAT *030 W P Serial port data and stop bits write
|
38 |
|
|
SERPER *032 W P Serial port period and control
|
39 |
|
|
\endverbatim
|
40 |
|
|
*/
|
41 |
|
|
|
42 |
|
|
module ocs_serial(
|
43 |
|
|
//% \name Clock and reset
|
44 |
|
|
//% @{
|
45 |
|
|
input CLK_I,
|
46 |
|
|
input reset_n,
|
47 |
|
|
//% @}
|
48 |
|
|
|
49 |
|
|
//% \name WISHBONE slave
|
50 |
|
|
//% @{
|
51 |
|
|
input CYC_I,
|
52 |
|
|
input STB_I,
|
53 |
|
|
input WE_I,
|
54 |
|
|
input [8:2] ADR_I,
|
55 |
|
|
input [3:0] SEL_I,
|
56 |
|
|
input [31:0] DAT_I,
|
57 |
|
|
output reg [31:0] DAT_O,
|
58 |
|
|
output reg ACK_O,
|
59 |
|
|
//% @}
|
60 |
|
|
|
61 |
|
|
//% \name Not aligned register access on a 32-bit WISHBONE bus
|
62 |
|
|
//% @{
|
63 |
|
|
// DSKBYTR read implemented here
|
64 |
|
|
output na_dskbytr_read,
|
65 |
|
|
input [15:0] na_dskbytr
|
66 |
|
|
//% @}
|
67 |
|
|
);
|
68 |
|
|
|
69 |
|
|
assign na_dskbytr_read =
|
70 |
|
|
(CYC_I == 1'b1 && STB_I == 1'b1 && WE_I == 1'b0 && { ADR_I, 2'b0 } == 9'h018 && SEL_I[1:0] != 2'b00 && ACK_O == 1'b0);
|
71 |
|
|
|
72 |
|
|
always @(posedge CLK_I or negedge reset_n) begin
|
73 |
|
|
if(reset_n == 1'b0) begin
|
74 |
|
|
DAT_O <= 32'd0;
|
75 |
|
|
ACK_O <= 1'b0;
|
76 |
|
|
end
|
77 |
|
|
else begin
|
78 |
|
|
if(CYC_I == 1'b1 && STB_I == 1'b1 && ACK_O == 1'b0) ACK_O <= 1'b1;
|
79 |
|
|
else ACK_O <= 1'b0;
|
80 |
|
|
|
81 |
|
|
if(CYC_I == 1'b1 && STB_I == 1'b1 && WE_I == 1'b0) begin
|
82 |
|
|
if({ ADR_I, 2'b0 } == 9'h018 && SEL_I[0] == 1'b1) DAT_O[7:0] <= na_dskbytr[7:0];
|
83 |
|
|
if({ ADR_I, 2'b0 } == 9'h018 && SEL_I[1] == 1'b1) DAT_O[15:8] <= na_dskbytr[15:8];
|
84 |
|
|
if({ ADR_I, 2'b0 } == 9'h018 && SEL_I[2] == 1'b1) DAT_O[23:16] <= 8'd0;
|
85 |
|
|
if({ ADR_I, 2'b0 } == 9'h018 && SEL_I[3] == 1'b1) DAT_O[31:24] <= 8'd0;
|
86 |
|
|
end
|
87 |
|
|
end
|
88 |
|
|
end
|
89 |
|
|
|
90 |
|
|
endmodule
|