This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
resources:char_drawer_serial [2020/06/04 14:03] nelson |
resources:char_drawer_serial [2020/06/08 10:55] (current) nelson |
||
---|---|---|---|
Line 34: | Line 34: | ||
| enable| Input | 1 | Raise this signal to start drawing. The drawing will continue until finished. To draw a new string you must lower and then raise this signal. | | | enable| Input | 1 | Raise this signal to start drawing. The drawing will continue until finished. To draw a new string you must lower and then raise this signal. | | ||
| done | Output | 1 | Active-high, indicating that the string is done drawing | | | done | Output | 1 | Active-high, indicating that the string is done drawing | | ||
- | | string_in | Input | MAX_CHARS * 8 | ASCII character string to draw, most-significant byte is drawn first. | | ||
| tx | Output | 1 | The serial out signal | | | tx | Output | 1 | The serial out signal | | ||
+ | | string_in | Input | MAX_CHARS * 8 | ASCII character string to draw, most-significant byte is drawn first. | | ||
+ | |||
Click the link below to download the CharDrawer_serial.sv file. | Click the link below to download the CharDrawer_serial.sv file. | ||
Line 55: | Line 56: | ||
// State Machine | // State Machine | ||
- | typedef enum logic[1:0] {A, B, C, D, ERR='X} StateType; | + | typedef enum logic[1:0] {ST_WAIT, ST_WAIT_SENT, ST_SENT, ST_DONE, ERR='X} StateType; |
StateType cs, ns; | StateType cs, ns; | ||
Line 78: | Line 79: | ||
always_ff @(posedge clk) | always_ff @(posedge clk) | ||
if (clrCnt) | if (clrCnt) | ||
- | cnt <= 0; | + | cnt <= 0; |
else if (incCnt) | else if (incCnt) | ||
cnt <= cnt + 1; | cnt <= cnt + 1; | ||
Line 93: | Line 94: | ||
done = 0; | done = 0; | ||
if (reset) | if (reset) | ||
- | ns = A; | + | ns = ST_WAIT; |
else case (cs) | else case (cs) | ||
- | A: begin | + | ST_WAIT: begin |
clrCnt = 1; | clrCnt = 1; | ||
if (enable) | if (enable) | ||
- | ns = B; | + | ns = ST_WAIT_SENT; |
else | else | ||
- | ns = A; | + | ns = ST_WAIT; |
end | end | ||
- | B: begin | + | ST_WAIT_SENT: begin |
send = 1; | send = 1; | ||
if (sent) | if (sent) | ||
- | ns = C; | + | ns = ST_SENT; |
else | else | ||
- | ns = B; | + | ns = ST_WAIT_SENT; |
end | end | ||
- | C: begin | + | ST_SENT: begin |
if (~sent && cnt != 15) begin | if (~sent && cnt != 15) begin | ||
incCnt = 1; | incCnt = 1; | ||
- | ns = B; | + | ns = ST_WAIT_SENT; |
end | end | ||
else if (~sent && cnt == 15) | else if (~sent && cnt == 15) | ||
- | ns = D; | + | ns = ST_DONE; |
else | else | ||
- | ns = C; | + | ns = ST_SENT; |
end | end | ||
- | D: begin | + | ST_DONE: begin |
done = 1; | done = 1; | ||
if (~enable) | if (~enable) | ||
- | ns = A; | + | ns = ST_WAIT; |
else | else | ||
- | ns = D; | + | ns = ST_DONE; |
end | end | ||
default: | default: |