diff options
author | FreeArtMan <dos21h@gmail.com> | 2018-12-03 00:28:25 +0000 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2018-12-03 00:28:25 +0000 |
commit | 7e00e4960af68e6c26104cca26cdf47f4f4095a7 (patch) | |
tree | 822ec720ca81994c9e7e534064d472d3debbb6f7 /cpu8/cpu_srlatch/cpu_srlatch.cpp | |
parent | 8a42a00d1392d882d4241ae92fbf7845f6791c5f (diff) | |
download | cpu8-7e00e4960af68e6c26104cca26cdf47f4f4095a7.tar.gz cpu8-7e00e4960af68e6c26104cca26cdf47f4f4095a7.zip |
Added initial CPU SR-latch
Diffstat (limited to 'cpu8/cpu_srlatch/cpu_srlatch.cpp')
-rw-r--r-- | cpu8/cpu_srlatch/cpu_srlatch.cpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/cpu8/cpu_srlatch/cpu_srlatch.cpp b/cpu8/cpu_srlatch/cpu_srlatch.cpp new file mode 100644 index 0000000..07efe5e --- /dev/null +++ b/cpu8/cpu_srlatch/cpu_srlatch.cpp @@ -0,0 +1,98 @@ +#include <iostream> +#include <iomanip> + +#include "systemc.h" +#include "systemc" +#include <sysc/tracing/sc_trace.h> +#include <sysc/tracing/sc_vcd_trace.h> + +#include "cpu_srlatch.hpp" + +SC_MODULE(test_cpu_srlatch) +{ + sc_out<bool> s,r; + sc_in<bool> clk; + + + void test_cpu_srlatch_stim() + { + wait(); + s.write(0); + r.write(1); + + wait(); + s.write(1); + r.write(0); + + wait(); + s.write(1); + r.write(1); + + wait(); + s.write(1); + r.write(0); + + wait(); + s.write(0); + r.write(0); + + + wait(); + s.write(0); + r.write(0); + + wait(); + s.write(0); + r.write(1); + + wait(); + s.write(0); + r.write(0); + + wait(); + s.write(0); + r.write(0); + + + wait(); + + sc_stop(); + } + + SC_CTOR(test_cpu_srlatch) + { + SC_THREAD(test_cpu_srlatch_stim); + sensitive << clk.pos(); + + } +}; + + +int sc_main(int argc, char **argv) { + sc_signal<bool> sig_in_r, sig_in_s, sig_out_q, sig_out_nq; + sc_clock TestClk("TestClk", 10, SC_NS, 0.5, 1, SC_NS); + + test_cpu_srlatch Stim1("Stimulus"); + Stim1.r(sig_in_r); + Stim1.s(sig_in_s); + Stim1.clk(TestClk); + + cpu_srlatch DUT("cpu_srlatch"); + DUT.in_r(sig_in_r); + DUT.in_s(sig_in_s); + DUT.out_q(sig_out_q); + DUT.out_nq(sig_out_nq); + + sc_trace_file *Tf; + + Tf = sc_create_vcd_trace_file("trace_cpu_srlatch.dat"); + sc_trace(Tf, sig_in_r, "IN_R"); + sc_trace(Tf, sig_in_s, "IN_S"); + sc_trace(Tf, sig_out_q, "OUT_Q"); + sc_trace(Tf, sig_out_nq, "OUT_NQ"); + + sc_start(); + sc_close_vcd_trace_file(Tf); + + return(0); +}
\ No newline at end of file |