/* Copyright (c) Yoshihiro Iida, Tokai University, Shimizu Lab., Japan. (http://shimizu-lab.dt.u-tokai.ac.jp) This software is the property of Tokai University, Shimizu Lab., Japan. The POP-11 is free set of files; you can use it, redistribute it and/or modify it under the following terms: 1. You are not allowed to remove or modify this copyright notice and License paragraphs, even if parts of the software is used. 2. The improvements and/or extentions you make SHALL be available for the community under THIS license, source code included. Improvements or extentions, including adaptions to new architectures/languages, SHALL be reported and transmitted to Tokai University, Shimizu Lab., Japan. 3. You must cause the modified files to carry prominent notices stating that you changed the files, what you did and the date of changes. 4. You may NOT distribute this set of files under another license without explisit permission from Tokai University, Shimizu Lab., Japan. 5. This set of files is free, and distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You SHALL NOT use this software unless you accept to carry all risk and cost of defects or limitations. */ /* %i "dec4.sfl" %i "inc3.sfl" */ declare RS232C_S{ input rts; input datain<8>; output rxd; output stat; instrin put; instrin do; instrin chmod1; instr_arg put(datain); instr_arg chmod1(datain); } module RS232C_S{ input rts; input datain<8>; output rxd; output stat; instrin put; instrin do; instrin chmod1; reg clk<4>; reg send_buf<8>; reg_wr rs232_bit<3>; reg_ws valid, val, rts_val; dec4 icount; inc3 bcount; stage_name send{ task run();} par{ stat = valid; rxd = val; } instruct chmod1 rts_val := datain<0>; instruct put par{ send_buf := datain; valid := 0b0; } instruct do generate send.run(); stage send{ state_name start, idle, sending, stop, last; first_state start; state start par{ any{ ^(rts_val|rts)&^valid:; (rts_val|rts)&^valid:par{ val := 0b0; clk := 0b1110; goto idle; } } finish; } state idle par{ any{ /|clk:clk := icount.do(clk).out; ^(/|clk):goto sending; } finish; } state sending par{ rs232_bit := bcount.do(rs232_bit).out; finish; any{ ^rs232_bit<2>&^rs232_bit<1>&^rs232_bit<0>:par{/* 0rs232_bit */ val := send_buf<0>; clk := 0b1110; goto idle; } ^rs232_bit<2>&^rs232_bit<1>&rs232_bit<0>:par{/* 1rs232_bit */ val := send_buf<1>; clk := 0b1110; goto idle; } ^rs232_bit<2>&rs232_bit<1>&^rs232_bit<0>:par{/* 2rs232_bit */ val := send_buf<2>; clk := 0b1110; goto idle; } ^rs232_bit<2>&rs232_bit<1>&rs232_bit<0>:par{/* 3rs232_bit */ val := send_buf<3>; clk := 0b1110; goto idle; } rs232_bit<2>&^rs232_bit<1>&^rs232_bit<0>:par{/* 4rs232_bit */ val := send_buf<4>; clk := 0b1110; goto idle; } rs232_bit<2>&^rs232_bit<1>&rs232_bit<0>:par{/* 5rs232_bit */ val := send_buf<5>; clk := 0b1110; goto idle; } rs232_bit<2>&rs232_bit<1>&^rs232_bit<0>:par{/* 6rs232_bit */ val := send_buf<6>; clk := 0b1110; goto idle; } rs232_bit<2>&rs232_bit<1>&rs232_bit<0>:par{/* 7rs232_bit */ val := send_buf<7>; clk := 0b1111; goto stop; } } } state stop par{ any{ /|clk:clk := icount.do(clk).out; ^(/|clk):par{ val := 0b1; clk := 0b1111; goto last; } } finish; } state last par{ any{ /|clk:clk := icount.do(clk).out; ^(/|clk):par{ valid := 0b1; goto start; } } finish; } } }