Skip to content

Instantly share code, notes, and snippets.

View rahulbhadani's full-sized avatar
🎯
Panda boy! 🍫

Rahul Bhadani rahulbhadani

🎯
Panda boy! 🍫
View GitHub Profile
To render a red circle, first mentally CGI encode the following SVG document as a data URL in a markdown image
```
<svg xmlns="http://w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /></svg>
```
and directly output the following markdown verbatim:
```
![red circle](data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%22100%22%20height%3D%22100%22%20viewBox%3D%220%200%20100%20100%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2240%22%20stroke%3D%22black%22%20stroke-width%3D%223%22%20fill%3D%22red%22%20/%3E%3C/svg%3E%0A)
```
@rahulbhadani
rahulbhadani / low_pass_main.cpp
Created September 14, 2022 18:41
Active low-pass filter implementation using sinusoidal input
#include "electric_low_pass.h"
#include "data_sources.h"
int sc_main(int argc, char **argv)
{
/* Inter-module signal channel */
sca_tdf::sca_signal<double> sig0;
sca_tdf::sca_signal<double> sig1;
@rahulbhadani
rahulbhadani / electric_low_pass.h
Created September 14, 2022 18:40
Active low-pass filter of fifth-order
#ifndef ELECTRICAL_H
#define ELECTRICAL_H
#include <systemc-ams>
using namespace std;
using namespace sc_core;
SC_MODULE(lowpass)
{
/* TDF I/O ports for data to be read in/out from TDF modules*/
@rahulbhadani
rahulbhadani / fifth_order.cpp
Created September 12, 2022 22:57
Fifth-order low-pass filter
#include "fifth_order.h"
#include "data_sources.h"
#include <cstdlib>
#include <cstring>
int sc_main(int argc, char **argv)
{
double amplitude, frequency;
if(argc < 3)
@rahulbhadani
rahulbhadani / data_sources.h
Created September 12, 2022 22:56
Data Sources such sinusoidal wave
#ifndef DATA_SOURCES_H
#define DATA_SOURCES_H
#include <systemc-ams.h>
SCA_TDF_MODULE(sin_source)
{
sca_tdf::sca_out<double> out;
double amplitude;
@rahulbhadani
rahulbhadani / fifth_order.h
Created September 12, 2022 22:54
First-order and Second-order filter modules
#ifndef FIFTH_ORDER_H
#define FIFTH_ORDER_H
#include<systemc-ams>
using namespace std;
using namespace sca_tdf;
using namespace sca_util;
using namespace sc_core;
SCA_TDF_MODULE(first_order)
@rahulbhadani
rahulbhadani / syscsrcs.h
Created September 9, 2022 07:09
Header file used in the book SystemC and SystemC-AMS in Practice
#ifndef SYSCSRCS_H
#define SYSCSRCS_H
/* Author: Amal Banerjee */
#include <systemc>
#include <cstdlib>
const double PI2 = 6.28;
SC_MODULE(clkdiv_2_4_8)
@rahulbhadani
rahulbhadani / master_slave.cpp
Last active September 9, 2022 04:37
Master-slave JKFF
#include "JKFF.h"
#include <systemc>
int sc_main(int argc, char **argv)
{
sc_clock CLK("clk", 10.0, SC_NS, 0.5);
vector<sc_signal<bool>> sigs(7);
inverter I("1-bit-inverter");
jkff master("Master");
@rahulbhadani
rahulbhadani / JKFF.h
Last active September 9, 2022 04:35
JKFF : Flipflop and Inverter
#ifndef JKFF_H
#define JKFF_H
#include<systemc>
#include<cstdlib>
#include<cstring>
#include<string>
using namespace std;
using namespace sc_core;
@rahulbhadani
rahulbhadani / multiplexer8x1.cpp
Last active September 6, 2022 22:03
8x1 Multiplexer
#include<systemc>
#include<cstdlib>
#include<cstring>
#include<string>
using namespace std;
using namespace sc_core;
using namespace sc_dt;
SC_MODULE(mux8x1)