{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Reference Buffer" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%pylab inline\n", "import numpy as np\n", "from caf_verilog.reference_buffer import ReferenceBuffer" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fs = 1\n", "n = np.arange(0,10000)\n", "x = np.exp(2*np.pi*0.15*n*1j)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Px, ff = psd(x,2**10, fs)\n", "plot(ff, 10*np.log10(Px))\n", "ylim([-80, 25])\n", "xlim([0, 0.2])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "rb = ReferenceBuffer(x[:100], name='tb_inst')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "rb.gen_tb()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from caf_verilog.io_helper import read_complex_output\n", "rb_output = read_complex_output(rb.test_output_filename)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "assert len(rb_output) == len(rb.buffer_quant)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for sim_iq,py_iq in zip(rb_output, rb.buffer_quant):\n", " assert sim_iq == py_iq" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.7" } }, "nbformat": 4, "nbformat_minor": 2 }